package com.efivestar.idm.api.config;

import com.efivestar.idm.api.util.tianyi.*;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TianyiWebServiceClient {

    @Value("${tianyi.webserviceUrl:http://www.189eyes.com:9000/cxf/MobileService}")
    private String tianyiWebserviceUrl;


    @Bean
    public MobileServicesPortType initMobileServicePortType(){
        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(MobileServicesPortType.class);
        factory.setAddress(tianyiWebserviceUrl);
        MobileServicesPortType service = (MobileServicesPortType)factory.create();
        return service;
    }

    public static void main(String[] args) throws Exception_Exception {
        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(MobileServicesPortType.class);
        factory.setAddress("http://www.189eyes.com:9000/cxf/MobileService");
        MobileServicesPortType service = (MobileServicesPortType)factory.create();

//        UserLoginReq userLoginReq = new UserLoginReq();
//        userLoginReq.setAccount("13270897393");
//        userLoginReq.setPassword("abcd123#");
//        UserLoginRes userLoginRes = service.userLogin(userLoginReq);
//
//        System.out.println("********************1:Reuslt Start********************");
//        System.out.println(userLoginRes.getResult());
//        System.out.println(userLoginRes.getLoginSession());
//        System.out.println("********************1:Reuslt End********************");

        GetPlayUrlHXReq getPlayUrlHXReq = new GetPlayUrlHXReq();
        getPlayUrlHXReq.setAccount("13270897393");
        getPlayUrlHXReq.setLoginSession("28c0a960c89e4d20b549879893a48f1f");
        // 设置摄像头id
        getPlayUrlHXReq.setDevID("241EMA1ONEZ");
        getPlayUrlHXReq.setChannelNo(0);
        // 标清视频
        getPlayUrlHXReq.setStreamType(2);
        GetPlayUrlHXRes playUrlHX = service.getPlayUrlHX(getPlayUrlHXReq);

        System.out.println("********************2:Reuslt Start********************");
        System.out.println(playUrlHX.getResult());
        System.out.println(playUrlHX.getRelayPlayUrl());
        System.out.println(playUrlHX.getDirectPlayUrl());
        System.out.println(playUrlHX.getLocalPlayUrl());
        System.out.println("********************2:Reuslt End********************");
    }

}
